<template>
	<view>
		<view style="width: 690upx;padding: 30upx;display: flex;">
			<view style="width: 600upx;background: #E3EBF6;display: flex;border-radius: 30upx;height: 60upx;">
				<image src="../../static/shangmen/sousuo.png" style="width: 32upx;height: 32upx;margin-top: 18upx;margin-left: 30upx;"></image>
				<input placeholder="请输入关键字" style="width: 500upx;margin-left: 12upx;font-size: 28upx;margin-top: 8upx;" :value="keyword" @confirm="confirm_tap" confirm-type="search" @input="input_tap"/>
			</view>
			<view @click="confirm_tap" style="color: #999999;font-size: 30upx;margin-top: 15upx;margin-left: 30upx;">搜索</view>
		</view>
		<view class="list" style="background: rgba(0, 0, 0, 0);">
			<view class="list_all" style="background: rgba(0, 0, 0, 0);">
				<view class="list_box" v-for="(item,index) in good_list" :key="index"
					@click="shop_details(item.goods_id,item)">
					<view style="background: #fff;border-radius: 80upx 0 0 0;">
						<image style="border-radius: 80upx 0 80upx 0;" class="list_box_image" mode="aspectFill" :src="item.image"></image>
					</view>
					<view style="background: #fff;margin-top: -10upx;padding: 10upx;border-radius: 0 0 20upx 20upx;">
						<view class="list_box_title">{{item.name}}</view>
						<view class="list_box_titles">￥{{item.price}}</view>
						<!-- <view class="list_box_titles">积分{{item.price}}</view> -->
					</view>
				</view>
				<view style="width: 100%;line-height: 100upx;font-size: 28upx;color: #999;text-align: center;" v-if="good_list.length == 0">暂无更多数据</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				keyword:'',
				good_list:[],
				page:1
			}
		},
		onLoad(num) {
			this.keyword = num.keyword
			this.goods_index_api()
		},
		methods: {
			//详情
			shop_details(goods_id,item) {
				uni.navigateTo({
					// url: '../shop_details/shop_details?goods_id=' + goods_id + '&key=1'
					url: '../shop_details/shop_details?goods_id=' + goods_id + '&key=3'
				})
			},
			input_tap(num) {
				this.keyword = num.detail.value
			},
			confirm_tap() {
				if( this.keyword != '' ) {
					// this.goods_type_api()
					this.goods_index_api()
				}
			},
			//普通商品
			goods_index_api() {
				var that = this
				that.$request(that.$Api.good_index_api, {
					access_token: uni.getStorageSync('access_token'),
					keyword:that.keyword,
					city:uni.getStorageSync('city'),
					page:that.page
				}, "POST").then(res => {
					if (res.data.code == 0) {
						that.good_list = res.data.data.list
					} else {
						uni.showToast({
							title: res.data.msg,
							duration: 2000,
							icon: 'none'
						});
					}
				})
			},
		},
		onReachBottom() {
			var that = this
			that.page++
			that.$request(that.$Api.goods_index_api, {
				access_token: uni.getStorageSync('access_token'),
				keyword:that.keyword,
				city:uni.getStorageSync('city'),
				page:that.page
			}, "POST").then(res => {
				if (res.data.code == 0) {
					if( res.data.data.list.length != 0 ) {
						that.good_list = that.good_list.concat(res.data.data.list)
					}
				} else {
					uni.showToast({
						title: res.data.msg,
						duration: 2000,
						icon: 'none'
					});
				}
			})
		}
	}
</script>

<style lang="less">
	.list {
		.title{
			.titlesss{
				font-size: 26upx;
				color: #666;
				height: 36upx;
				line-height: 36upx;
			}
			.titless{
				font-size: 32upx;
				font-weight: bold;
				height: 36upx;
				line-height: 36upx;
				margin-left: 10upx;
			}
			.titles{
				width: 10upx;
				height: 36upx;
				background: #cf4052;
			}
			width: 700upx;
			margin-left: 25upx;
			display: flex;
			justify-content: space-between;
			border-bottom: 1upx solid #eee;
		}
		.hot_top {
			font-size: 32upx;
			font-weight: bold;
			padding: 25upx;
		}
	
		.list_all {
			.list_box {
				.list_box_titles {
					font-size: 28upx;
					font-weight: bold;
					color: #EA4E29;
					line-height: 34upx;
					padding-bottom: 20upx;
					// margin-top: 8upx;
				}
	
				.list_box_title {
					width: 330upx;
					// height: 42upx;
					font-size: 28upx;
					color: #333333;
					line-height: 34upx;
					// margin-top: 18upx;
				}
	
				.list_box_image {
					width: 345upx;
					height: 345upx;
					border-radius: 50upx 0upx 50upx 0upx;			
					image {
						background: #fff;
					}
				}
	
				width: 345upx;
				padding-top: 16upx;
			}
	
			width: 700upx;
			display: flex;
			justify-content: space-between;
			flex-direction: row;
			flex-wrap: wrap;
			padding: 0 25upx;
		}
	
		width: 750upx;
		padding: 0 0 25upx 0;
		background: #fff;
	}
</style>
